package com.study.interface_demo3;

import java.util.ArrayList;

public class ClassDataImpl1 implements ClassData{
    private ArrayList<Student> students;
    public ClassDataImpl1(ArrayList<Student> students) {
        this.students=students;
    }

    @Override
    public void printAllStudentsInfo() {
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println(student.getName()+" "+student.getSex()+" " + student.getScore());
        }
    }

    @Override
    public void printAllStudentsAverageScore() {
        double sumScore = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            sumScore+=student.getScore();
        }
        System.out.println(sumScore/ students.size());
    }
}
